# 默认编译选项
PRE_COMPILE_DEBUG ?= 0
SELF ?= 0

# 根据 PRE_COMPILE_DEBUG 和 SELF 的值设置编译选项
ifeq ($(PRE_COMPILE_DEBUG), 1)
    CXXFLAGS += -DPRE_COMPILE_DEBUG=1
endif

ifeq ($(SELF), 1)
    CXXFLAGS += -DSELF=1
endif

# 编译器和链接器选项
CXX = g++
CXXFLAGS += -std=c++17
LDFLAGS = -lpthread -ljsoncpp

# 目标文件
TARGETS = server_tcp client_tcp

.PHONY: all
all: $(TARGETS)

server_tcp: TcpServer.cc
	$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)

client_tcp: TcpClient.cc
	$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)

.PHONY: clean
clean:
	rm -f $(TARGETS)